<?php
include '../JHeader.php';
if(isset($_GET['page']) && isset($_GET['id']))
    {
        $page = $_GET['page'];
        $id   = $_GET['id'];
        /**
        * Funktion, um das Menü anzuzeigen.
        *
        * @author Timo
        */
        function ShowMenu($selected, $id)
        {
            echo '<table>';
            echo '<tr class="first_row">';
            if($selected == 'drivers')
            {
                echo '<td class="drivers_active"><a href="index.php?page=drivers&id=' . $id . '">Fahrer</a></td>';
            }
            else
            {
                echo '<td class="drivers"><a href="index.php?page=drivers&id=' . $id . '">Fahrer</a></td>';
            }
            if($selected == 'driver_rankings')
            {
                echo '<td class="driver_rankings_active"><a href="index.php?page=driver_rankings&id=' . $id . '">Fahrerwertung</a></td>';
            }
            else
            {
                echo '<td class="driver_rankings"><a href="index.php?page=driver_rankings&id=' . $id . '">Fahrerwertung</a></td>';
            }
            if($selected == 'single_results')
            {
                echo '<td class="single_results_active"><a href="index.php?page=single_results&id=' . $id . '">Rennkalender</a></td>';
            }
            else
            {
                echo '<td class="single_results"><a href="index.php?page=single_results&id=' . $id . '">Rennkalender</a></td>';
            }
            echo '</tr>';
            echo '<tr class="second_row">';
            if($selected == 'teams')
            {
                echo '<td class="teams_active"><a href="index.php?page=teams&id=' . $id . '">Teams</a></td>';
            }
            else
            {
                echo '<td class="teams"><a href="index.php?page=teams&id=' . $id . '">Teams</a></td>';
            }
            if($selected == 'team_rankings')
            {
                echo '<td class="team_rankings_active"><a href="index.php?page=team_rankings&id=' . $id . '">Teamwertung</a></td>';
            }
            else
            {
                echo '<td class="team_rankings"><a href="index.php?page=team_rankings&id=' . $id . '">Teamwertung</a></td>';
            }
            if($selected == 'fairplay_rankings')
            {
                echo '<td class="fairplay_rankings_active"><a href="index.php?page=fairplay_rankings&id=' . $id . '">Fairplay-Wertung</a></td>';
            }
            else
            {
                echo '<td class="fairplay_rankings"><a href="index.php?page=fairplay_rankings&id=' . $id . '">Fairplay-Wertung</a></td>';
            }
            echo '</tr>';
            echo '</table>';
        }

        function ShowContent($page)
        {
            switch($page)
            {
                case 'drivers': include 'drivers.php';
                                break;
                case 'teams': include 'teams.php';
                            break;
                case 'driver_rankings': include 'driver_rankings.php';
                                        break;
                case 'team_rankings': include 'team_rankings.php';
                                    break;
                case 'single_results': include 'single_results.php';
                                    break;
                case 'fairplay_rankings': include 'fairplay_rankings.php';
                                        break;

                default: include 'drivers.php?id=' . $id;
                        break;
            }
        }

/**
 * Das Template für die späteren Tabellen und Wertungen.
 * In der css-Datei kann das Aussehen dieser verändert werden.
 *
 * @author Timo
 */
?>
<!DOCTYPE html>
<html>
    <head>
        <title>MSP Ranking</title>
         <link rel="stylesheet" type="text/css" href="css/default.css" />
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    <body>
        <div id="main">
            <div id="tabmenu">
                <?php ShowMenu($page, $id); ?>
            </div>
            <div id="content">
                <?php ShowContent($page, $id); ?>
            </div>
        </div>
        <div id="footer">[version alpha 0.9]</div>
    </body>
</html>
<?php
    }
    else
    {
        echo 'ERROR';
    }
?>